package gui;

import java.util.Locale;
import java.util.ResourceBundle;
import java.util.prefs.Preferences;

import javax.swing.JInternalFrame;
import javax.swing.WindowConstants;

import org.apache.log4j.Logger;

/**
 * Trida pro vnitrni okno
 * 
 * @author dove
 * 
 */
public class InternalFrame extends JInternalFrame {

	private static final long serialVersionUID = 1L;

	protected Preferences prefs;

	protected ResourceBundle messages;

	private String language;

	protected static final Logger logger = Logger.getLogger("Log");

	/**
	 * Nastavuje okno
	 * 
	 * @param name
	 *            nazev okna
	 */
	public InternalFrame(String name) {
		super(name, true, // resizable
				false, // closable
				false, // maximizable
				false);// iconifiable

		this.setVisible(true);

		this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

		prefs = Preferences.userRoot();
		language = prefs.get("Language", "en");
		Locale currentLocale = new Locale(language);
		messages = ResourceBundle.getBundle("Lang", currentLocale);
	}

	/**
	 * Nastavuje pozici okna
	 * 
	 * @param xOffset
	 *            X pozice
	 * @param yOffset
	 *            Y pozice
	 */
	public void setPosition(int xOffset, int yOffset) {
		this.setLocation(xOffset, yOffset);
	}

	/**
	 * Vraci okno
	 * 
	 * @return okno
	 */
	public JInternalFrame getWindow() {
		return this;
	}
}